package com.cloud.lawcase.common.config;

import java.util.HashSet;
import java.util.Set;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerConfiguration {
	private static final Set<String> consumes = new HashSet<String>(){
		private static final long serialVersionUID = 1L; {
		add("application/x-www-form-urlencoded");
	}};
	
	@Bean
	public Docket createRestApi(){
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.forCodeGeneration(false)
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.cloud.lawcase.api.web"))
				.paths(PathSelectors.any())
				.build().consumes(consumes);
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("执法依据平台接口规范")
				.description("对外提供调用接口")
				.termsOfServiceUrl("")
				.version("1.0")
				.build();
	}
}
